package com.foreveredu.propms.domain;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;

/**
 * Description:<br/>
 * 领域模型：账户类，每个业主拥有一个账户，可用于预交物业费用<br/>
 * Date:<br/>
 * 2013/6/5<br/>
 * 
 * @author hushigang
 */

@Entity
@Table(name = "T_Accout")
public class Account {

	private int id;// 账户编号
	private Owner owner;// 所属业主
	private float balance;// 账户余额
	private String lastUsedDate;// 最近使用时间
	private Set<SubAccount> subAccounts;// 子账户集合

	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	@ManyToOne
	@JoinColumn(name = "owner_id")
	public Owner getOwner() {
		return owner;
	}

	public void setOwner(Owner owner) {
		this.owner = owner;
	}

	@Column
	public float getBalance() {
		return balance;
	}

	public void setBalance(float balance) {
		this.balance = balance;
	}

	@Column
	public String getLastUsedDate() {
		return lastUsedDate;
	}

	public void setLastUsedDate(String lastUsedDate) {
		this.lastUsedDate = lastUsedDate;
	}

	@OneToMany(mappedBy = "account")
	@OrderBy(value = "id ASC")
	public Set<SubAccount> getSubAccounts() {
		return subAccounts;
	}

	public void setSubAccounts(Set<SubAccount> subAccounts) {
		this.subAccounts = subAccounts;
	}

}
